//
//  DetailsViewController.m
//  We_Travel
//
//  Created by lanou3g on 15/12/14.
//  Copyright © 2015年 lanou3g. All rights reserved.
//

#import "DetailsViewController.h"
#import "CoreDataToolHelper.h"
#import "NH_DataDownloadTools.h"
#import "url.h"
#import "SiteRecomendModel.h"
#import "SiteManager.h"

@interface DetailsViewController ()

@end

@implementation DetailsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}
- (IBAction)didClickAddSiteAction:(UIButton *)sender {
    NSLog(@"%ld",self.attractionModel.mtu_id);
    [NH_DataDownloadTools downloadDataWithURL:[NSString stringWithFormat:HT_DetialSiteUrl,self.attractionModel.mtu_id] andMethod:@"get" andBody:nil andBlock:^(NSData *data) {
        NSDictionary *dictoionary = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
        SiteRecomendModel *model = [[SiteRecomendModel alloc]init];
        [model setValuesForKeysWithDictionary:dictoionary];
        NSIndexPath *index = [SiteManager shareSiteManager].indexPath;
        if (index.section == 0) {
            [[SiteManager shareSiteManager].mornArray insertObject:model atIndex:index.row/2];
        } else if (index.section == 1){
            [[SiteManager shareSiteManager].afteArray insertObject:model atIndex:index.row/2];
        } else if (index.section == 2){
            [[SiteManager shareSiteManager].evenArray insertObject:model atIndex:index.row/2];
        }
    }];
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
